/**
 */
package nump2cs.impl;

import java.util.Collection;

import nump2cs.AttributeTarget;
import nump2cs.AttributeTypeDeclaration;
import nump2cs.Nump2csPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Attribute Type Declaration</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link nump2cs.impl.AttributeTypeDeclarationImpl#isAllowMultiple <em>Allow Multiple</em>}</li>
 *   <li>{@link nump2cs.impl.AttributeTypeDeclarationImpl#isInherited <em>Inherited</em>}</li>
 *   <li>{@link nump2cs.impl.AttributeTypeDeclarationImpl#getTarget <em>Target</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class AttributeTypeDeclarationImpl extends TypeDeclarationImpl implements AttributeTypeDeclaration {
	/**
	 * The default value of the '{@link #isAllowMultiple() <em>Allow Multiple</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isAllowMultiple()
	 * @generated
	 * @ordered
	 */
	protected static final boolean ALLOW_MULTIPLE_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isAllowMultiple() <em>Allow Multiple</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isAllowMultiple()
	 * @generated
	 * @ordered
	 */
	protected boolean allowMultiple = ALLOW_MULTIPLE_EDEFAULT;

	/**
	 * The default value of the '{@link #isInherited() <em>Inherited</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isInherited()
	 * @generated
	 * @ordered
	 */
	protected static final boolean INHERITED_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isInherited() <em>Inherited</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isInherited()
	 * @generated
	 * @ordered
	 */
	protected boolean inherited = INHERITED_EDEFAULT;

	/**
	 * The cached value of the '{@link #getTarget() <em>Target</em>}' attribute list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTarget()
	 * @generated
	 * @ordered
	 */
	protected EList<AttributeTarget> target;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AttributeTypeDeclarationImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return Nump2csPackage.Literals.ATTRIBUTE_TYPE_DECLARATION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isAllowMultiple() {
		return allowMultiple;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAllowMultiple(boolean newAllowMultiple) {
		boolean oldAllowMultiple = allowMultiple;
		allowMultiple = newAllowMultiple;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Nump2csPackage.ATTRIBUTE_TYPE_DECLARATION__ALLOW_MULTIPLE, oldAllowMultiple, allowMultiple));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isInherited() {
		return inherited;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setInherited(boolean newInherited) {
		boolean oldInherited = inherited;
		inherited = newInherited;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Nump2csPackage.ATTRIBUTE_TYPE_DECLARATION__INHERITED, oldInherited, inherited));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<AttributeTarget> getTarget() {
		if (target == null) {
			target = new EDataTypeUniqueEList<AttributeTarget>(AttributeTarget.class, this, Nump2csPackage.ATTRIBUTE_TYPE_DECLARATION__TARGET);
		}
		return target;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case Nump2csPackage.ATTRIBUTE_TYPE_DECLARATION__ALLOW_MULTIPLE:
				return isAllowMultiple();
			case Nump2csPackage.ATTRIBUTE_TYPE_DECLARATION__INHERITED:
				return isInherited();
			case Nump2csPackage.ATTRIBUTE_TYPE_DECLARATION__TARGET:
				return getTarget();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case Nump2csPackage.ATTRIBUTE_TYPE_DECLARATION__ALLOW_MULTIPLE:
				setAllowMultiple((Boolean)newValue);
				return;
			case Nump2csPackage.ATTRIBUTE_TYPE_DECLARATION__INHERITED:
				setInherited((Boolean)newValue);
				return;
			case Nump2csPackage.ATTRIBUTE_TYPE_DECLARATION__TARGET:
				getTarget().clear();
				getTarget().addAll((Collection<? extends AttributeTarget>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case Nump2csPackage.ATTRIBUTE_TYPE_DECLARATION__ALLOW_MULTIPLE:
				setAllowMultiple(ALLOW_MULTIPLE_EDEFAULT);
				return;
			case Nump2csPackage.ATTRIBUTE_TYPE_DECLARATION__INHERITED:
				setInherited(INHERITED_EDEFAULT);
				return;
			case Nump2csPackage.ATTRIBUTE_TYPE_DECLARATION__TARGET:
				getTarget().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case Nump2csPackage.ATTRIBUTE_TYPE_DECLARATION__ALLOW_MULTIPLE:
				return allowMultiple != ALLOW_MULTIPLE_EDEFAULT;
			case Nump2csPackage.ATTRIBUTE_TYPE_DECLARATION__INHERITED:
				return inherited != INHERITED_EDEFAULT;
			case Nump2csPackage.ATTRIBUTE_TYPE_DECLARATION__TARGET:
				return target != null && !target.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (allowMultiple: ");
		result.append(allowMultiple);
		result.append(", Inherited: ");
		result.append(inherited);
		result.append(", target: ");
		result.append(target);
		result.append(')');
		return result.toString();
	}

} //AttributeTypeDeclarationImpl
